Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding new accounts summary query #2527

Merged
merged 9 commits into from
May 17, 2024
Merged

Conversation

gsk967
Copy link
Collaborator

@gsk967 gsk967 commented May 16, 2024

Description


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • added appropriate labels to the PR
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@gsk967 gsk967 requested a review from a team as a code owner May 16, 2024 10:46
Copy link
Contributor

coderabbitai bot commented May 16, 2024

Walkthrough

The updates enhance the leverage module by integrating account summaries, both individually and collectively. This involves adding new functions, parameters, and RPC methods to handle these summaries. The changes span across initialization logic, gRPC-web API, and CLI queries, ensuring comprehensive account data management.

Changes

Files Change Summary
app/app.go Added app.AccountKeeper and keys[authtypes.StoreKey] as parameters to the New function for initializing app.LeverageKeeper.
proto/umee/leverage/v1/query.proto Added import for pagination.proto and defined new RPC method AccountSummaries with related messages.
x/leverage/client/cli/query.go Added QueryAccountSummaries function to query USD values for all accounts' positions and borrowing limits.
x/leverage/keeper/accounts_summary.go Introduced functions for querying account summaries, including calculations of supplied, borrowed, and collateral values.
x/leverage/keeper/grpc_query.go Removed AccountSummary function, redistributing its logic elsewhere.
x/leverage/keeper/internal_test.go Updated NewTestKeeper function to include new parameters akStoreKey and ak for authkeeper.AccountKeeper.
x/leverage/keeper/keeper.go Added akStoreKey and authKeeper to Keeper struct and updated NewKeeper function to accept these new parameters.
x/leverage/keeper/suite_test.go Added import for authtypes.
CHANGELOG.md Documented the addition of accounts_summary gRPC-web API and CLI query to the leverage module.

In code we trust, as bytes align,
New functions bloom, in structured time.
With summaries clear, and queries bright,
We leverage change, from dark to light.
A rabbit's joy, in code's embrace,
Hopping through lines, at a steady pace.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 682c059 and 4b574f4.
Files ignored due to path filters (2)
  • x/leverage/types/query.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • x/leverage/types/query.pb.gw.go is excluded by !**/*.pb.gw.go, !**/*.pb.gw.go
Files selected for processing (8)
  • app/app.go (1 hunks)
  • proto/umee/leverage/v1/query.proto (3 hunks)
  • x/leverage/client/cli/query.go (2 hunks)
  • x/leverage/keeper/accounts_summary.go (1 hunks)
  • x/leverage/keeper/grpc_query.go (1 hunks)
  • x/leverage/keeper/internal_test.go (2 hunks)
  • x/leverage/keeper/keeper.go (4 hunks)
  • x/leverage/keeper/suite_test.go (2 hunks)
Files not reviewed due to errors (2)
  • x/leverage/keeper/keeper.go (no review received)
  • proto/umee/leverage/v1/query.proto (no review received)
Files skipped from review due to trivial changes (1)
  • x/leverage/keeper/grpc_query.go
Additional comments not posted (7)
x/leverage/keeper/internal_test.go (2)

7-7: Import statement for authkeeper looks good.


26-37: Changes to NewTestKeeper function are consistent and correct.

x/leverage/keeper/accounts_summary.go (3)

3-13: Import statements are correctly added and necessary for the new functionality.


15-89: The accountSummary function is well-structured and handles errors appropriately.


92-121: The AccountsSummary function correctly handles pagination and error cases.

x/leverage/keeper/suite_test.go (1)

71-73: Changes to the SetupTest function are consistent and ensure correct test setup.

app/app.go (1)

493-495: Ensure the added parameters are correctly used and integrated.

The addition of keys[authtypes.StoreKey] and app.AccountKeeper as parameters to the LeverageKeeper initialization looks correct. Verify that these parameters are necessary and correctly used within the LeverageKeeper implementation.

Verification successful

The addition of keys[authtypes.StoreKey] and app.AccountKeeper as parameters to the LeverageKeeper initialization appears to be correct. The AccountKeeper is used in both the implementation (keeper.go) and test files (internal_test.go). However, keys[authtypes.StoreKey] does not appear to be directly referenced, which might indicate it is used indirectly or referenced differently.

  • authkeeper.AccountKeeper is declared and used in keeper.go and internal_test.go.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of the added parameters in the LeverageKeeper implementation.

# Test: Search for the usage of `keys[authtypes.StoreKey]` and `app.AccountKeeper` in the LeverageKeeper implementation.
rg --type go 'keys\[authtypes.StoreKey\]' x/leverage/keeper/
rg --type go 'app.AccountKeeper' x/leverage/keeper/

Length of output: 332



Script:

#!/bin/bash
# Description: Verify the usage of the added parameters in the LeverageKeeper implementation.

# Test: Search for the usage of `keys[authtypes.StoreKey]` in the LeverageKeeper implementation.
rg --type go 'keys\[authtypes.StoreKey\]' x/leverage/keeper/ --files-without-match

# Test: Search for the usage of `AccountKeeper` in the LeverageKeeper implementation.
rg --type go 'AccountKeeper' x/leverage/keeper/ --files-without-match

Length of output: 3163



Script:

#!/bin/bash
# Description: Extract specific lines where `keys[authtypes.StoreKey]` and `AccountKeeper` are used in the LeverageKeeper implementation.

# Extract lines for `keys[authtypes.StoreKey]`
rg --type go 'keys\[authtypes.StoreKey\]' x/leverage/keeper/

# Extract lines for `AccountKeeper`
rg --type go 'AccountKeeper' x/leverage/keeper/

Length of output: 602



Script:

#!/bin/bash
# Description: Review specific lines in keeper.go and internal_test.go for correct usage of AccountKeeper.

# Extract specific lines in keeper.go
rg --type go 'authkeeper.AccountKeeper' x/leverage/keeper/keeper.go

# Extract specific lines in internal_test.go
rg --type go 'authkeeper.AccountKeeper' x/leverage/keeper/internal_test.go

Length of output: 251

x/leverage/client/cli/query.go Outdated Show resolved Hide resolved
x/leverage/client/cli/query.go Outdated Show resolved Hide resolved
x/leverage/client/cli/query.go Outdated Show resolved Hide resolved
app/app.go Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 4b574f4 and 29bb1ae.
Files selected for processing (1)
  • x/leverage/client/cli/query.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/leverage/client/cli/query.go

@gsk967 gsk967 requested a review from robert-zaremba May 16, 2024 14:10
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 29bb1ae and d741069.
Files selected for processing (1)
  • app/app.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/app.go

@gsk967 gsk967 enabled auto-merge May 16, 2024 15:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between d741069 and dbaa39f.
Files selected for processing (1)
  • x/leverage/keeper/accounts_summary.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/leverage/keeper/accounts_summary.go

Copy link

codecov bot commented May 16, 2024

Codecov Report

Attention: Patch coverage is 32.07547% with 72 lines in your changes are missing coverage. Please review.

Project coverage is 62.60%. Comparing base (7f05ad4) to head (0cfed98).
Report is 478 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #2527       +/-   ##
===========================================
- Coverage   75.38%   62.60%   -12.79%     
===========================================
  Files         100      276      +176     
  Lines        8025    15944     +7919     
===========================================
+ Hits         6050     9982     +3932     
- Misses       1589     5189     +3600     
- Partials      386      773      +387     
Files Coverage Δ
app/app.go 92.86% <100.00%> (ø)
x/leverage/keeper/grpc_query.go 66.81% <ø> (-0.40%) ⬇️
x/leverage/keeper/keeper.go 60.16% <100.00%> (-9.89%) ⬇️
x/leverage/client/cli/query.go 50.58% <0.00%> (ø)
x/leverage/keeper/accounts_summary.go 37.03% <37.03%> (ø)

... and 233 files with indirect coverage changes

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between dbaa39f and 2c0c0df.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Files not reviewed due to errors (1)
  • CHANGELOG.md (no review received)
Additional Context Used
LanguageTool (12)
CHANGELOG.md (12)

Near line 115: Using ‘plenty’ without ‘of’ is considered to be informal.
Context: .../pull/2368) Fix inflow amount calculation. Previously, the inflow amount of the t...


Near line 217: Did you mean “limiting”? Or maybe you should add a pronoun? In active voice, ‘allow’ + ‘to’ takes an object, usually a pronoun.
Context: ...veragedLiquidate.MaxRepay` which allows to limit the liquidation size using the leverage...


Near line 350: The singular proper name ‘Bridge’ must be used with a third-person or a past tense verb.
Context: ...-network/umee/pull/1967) Gravity Bridge phase out phase-2: disable Umee -> Ethereum t...


Near line 351: The singular proper name ‘Bridge’ must be used with a third-person or a past tense verb.
Context: ...-network/umee/pull/1967) Gravity Bridge phase out phase-2: disable Umee -> Ethereum t...


Near line 401: Make sure that the singular noun after the number ‘4.1’ is correct.
Context: ...e/pull/1807) Fixes BNB ibc denom in 4.1 migration - [1812](https://github.com/umee-networ...


Near line 419: In contexts where ‘if’ is followed by ‘or’, using ‘whether’ may be more appropriate (and formal).
Context: ...rowandMsgRepay` won't return errors if there is nothing to withdraw, borrow or...


Near line 466: Possible missing article found.
Context: ...of the build process (you must build on same host as you run the binary, or copy the...


Near line 470: Possible typo: you repeated a word
Context: ...e/pull/1555) Updates IBC to v5.1.0 that adds adds optional memo field to `FungibleTokenPa...


Near line 527: A comma may be missing after the conjunctive/linking adverb ‘Also’.
Context: ...ableLend, docs, and internal functions. Also QueryLoaned similar queries to QuerySup...


Near line 531: This word is normally spelled as one.
Context: ...roto getters in x/leverage and x/oracle proto types. - [1126](https://github.com/umee-netwo...


Near line 552: Possible missing comma found.
Context: ...umee/pull/1157) Added PrintOrErr util function optimizing the CLI code flow. - [1118](...


Near line 650: Possible typo: you repeated a word
Context: ...k/umee/pull/1358/files) Disable Gravity Bridge bridge messages. ### Improvements - [#1355](...

Copy link
Member

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • it's enough to iterate accounts that supplies something. Account that didn't supply anything can't collaterize nor borrow
  • There are typos

proto/umee/leverage/v1/query.proto Outdated Show resolved Hide resolved
x/leverage/client/cli/query.go Outdated Show resolved Hide resolved
x/leverage/keeper/accounts_summary.go Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2c0c0df and 5f4acac.
Files ignored due to path filters (2)
  • x/leverage/types/query.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • x/leverage/types/query.pb.gw.go is excluded by !**/*.pb.gw.go, !**/*.pb.gw.go
Files selected for processing (3)
  • proto/umee/leverage/v1/query.proto (3 hunks)
  • x/leverage/client/cli/query.go (2 hunks)
  • x/leverage/keeper/accounts_summary.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • x/leverage/client/cli/query.go
  • x/leverage/keeper/accounts_summary.go
Additional comments not posted (4)
proto/umee/leverage/v1/query.proto (4)

9-9: Import statement for pagination added.


58-62: New RPC method AccountSummaries added to the Query service.


351-355: New message QueryAccountSummaries added with pagination support.


357-368: New messages AccountSummary and QueryAccountSummariesResponse added.

@gsk967 gsk967 requested a review from robert-zaremba May 16, 2024 16:54
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 5f4acac and 0cfed98.
Files selected for processing (1)
  • x/leverage/keeper/accounts_summary.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/leverage/keeper/accounts_summary.go

@gsk967 gsk967 added this pull request to the merge queue May 17, 2024
Merged via the queue into main with commit 84f3562 May 17, 2024
22 of 27 checks passed
@gsk967 gsk967 deleted the sai/update_account_summary_query branch May 17, 2024 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants